package com.yunnuo.com;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 启动类
 * @author yunnuo
 * @since 2022-04-09
 */
@Slf4j
@SpringBootApplication
public class App {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
        Environment environment = context.getBean(Environment.class);

        try {
            log.info("\n😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉😉\n\n\t" +
                    environment.getProperty("spring.application.name") + " 成功运行 ! Access URLs:\n\t" +
                    "内部接口访问：http://127.0.0.1:" + environment.getProperty("server.port") + "\n\t" +
                    "局域网接口访问：http://" + InetAddress.getLocalHost().getHostAddress() + ":" + environment.getProperty("server.port")+
                    "\n😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍\n");
        } catch (UnknownHostException e) {
            log.error("未知错误：{}", e.getMessage(), e);
        }
    }

}
